package cn.itsource.ymcc;

import cn.itsource.ymcc.doc.CourseDoc;
import cn.itsource.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseFeignClientFallBackFactory implements FallbackFactory<SearchFeignClient> {

    @Override
    public SearchFeignClient create(Throwable throwable) {
        return new SearchFeignClient() {
            @Override
            public JSONResult saveCourse(CourseDoc doc) {
                throwable.printStackTrace();
                return JSONResult.error("你在搜什么？？");
            }
            @Override
            public JSONResult deleteCourse(Long courseId) {
                return JSONResult.error("ES搜索服务不可达");
            }
        };

    }
}
